//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.baomidou.mybatisplus.generator.config.builder;

import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.generator.ITemplate;
import com.baomidou.mybatisplus.generator.config.INameConvert;
import com.baomidou.mybatisplus.generator.config.INameConvert.DefaultNameConvert;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.function.ConverterFileName;
import com.baomidou.mybatisplus.generator.util.ClassUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class PageVo implements ITemplate {
    private static final Logger LOGGER = LoggerFactory.getLogger(Vo.class);
    private INameConvert nameConvert;
    private boolean chain;
    private boolean lombok;
    private NamingStrategy naming;
    private NamingStrategy columnNaming;
    private ConverterFileName converterFileName;

    private PageVo() {
        this.naming = NamingStrategy.underline_to_camel;
        this.columnNaming = null;
        this.converterFileName = (voName) -> {
            return voName;
        };
    }

    public void convertSuperVoColumns(Object clazz) {
        Class clazz1 = (Class) clazz;
        List<Field> fields = TableInfoHelper.getAllFields(clazz1);
    }

    @NotNull
    public NamingStrategy getColumnNaming() {
        return (NamingStrategy)Optional.ofNullable(this.columnNaming).orElse(this.naming);
    }

    @NotNull
    public INameConvert getNameConvert() {
        return this.nameConvert;
    }

    public boolean isChain() {
        return this.chain;
    }

    public boolean isLombok() {
        return this.lombok;
    }
    

    @NotNull
    public NamingStrategy getNaming() {
        return this.naming;
    }
    

    @NotNull
    public ConverterFileName getConverterFileName() {
        return this.converterFileName;
    }

    @NotNull
    public Map<String, Object> renderData(@NotNull TableInfo tableInfo) {
        Map<String, Object> data = new HashMap<>();
        data.put("voBuilderModel", this.chain);
        data.put("chainModel", this.chain);
        data.put("voLombokModel", this.lombok);
        return data;
    }

    public static class Builder extends BaseBuilder {
        private final PageVo pageVo = new PageVo();

        public Builder(StrategyConfig strategyConfig) {
            super(strategyConfig);
            this.pageVo.nameConvert = new DefaultNameConvert(strategyConfig);
        }

        public Builder nameConvert(INameConvert nameConvert) {
            this.pageVo.nameConvert = nameConvert;
            return this;
        }

        public Builder enableChainModel() {
            this.pageVo.chain = true;
            return this;
        }

        public Builder enableLombok() {
            this.pageVo.lombok = true;
            return this;
        }

        public Builder naming(NamingStrategy namingStrategy) {
            this.pageVo.naming = namingStrategy;
            return this;
        }

        public Builder columnNaming(NamingStrategy namingStrategy) {
            this.pageVo.columnNaming = namingStrategy;
            return this;
        }
        public Builder convertFileName(@NotNull ConverterFileName converter) {
            this.pageVo.converterFileName = converter;
            return this;
        }

        public Builder formatPageVoFileName(String format) {
            return this.convertFileName((pageVoName) -> String.format(format, pageVoName));
        }

        public PageVo get() {
            return this.pageVo;
        }

        private Optional<Class<?>> tryLoadClass(String className) {
            try {
                return Optional.of(ClassUtils.toClassConfident(className));
            } catch (Exception var3) {
                return Optional.empty();
            }
        }
    }
}
